// alle vierkantjes tracken
// als vierkantje in frame weinig is verschoven is dat vorige gezicht
// alleen nieuwe vierkantjes aan linkerkant
// history bijhouden
// vierkantje mag x aantal frames gemist worden


////////////////////////////////////////////////////////////////////////
// a3.cpp
//
// Third assignment for Advanced Multimedia Computing
//
// T. Kostelijk & F. Huizinga
//     0418889      0418862
//
////////////////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cv.h>
#include <highgui.h>

int main(int argc, char **argv) {
	char buf[256];
	IplImage *img;
    CvVideoWriter *videowriter = cvCreateVideoWriter("out.avi", CV_FOURCC('M','J','P','G'), 20, cvSize(img->width, img->height));

	// Show the final image
    cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE); 
	// load image 
	for (int i=100;i<200;i++){
		sprintf(buf,"data/movie1/00000%d.png", i);
		img = cvLoadImage(buf);

		if(!img){
			printf("Could not load image file: %s\n",buf);
			exit(0);
		}
		cvShowImage("mainWin", img );
		cvWaitKey(0);

		cvWriteFrame(videowriter, img);
	}


	// clear the memory
	cvReleaseImage( &img );
    cvReleaseVideoWriter( &videowriter );

    return 0;
}
